<?php

/**
 * 用户列表
 *
 */
function li($page_size = ADM_PAGESIZE) {
    global $_TABLES, $class_var;

    $view_var   = array();
    $tbl_ad     = $_TABLES['account_log'];
    $conn   = & get_db_conn();

    $where      = 'WHERE 1 ';
    // 关键字
	$uid=$_GET["userid"];
	
	
	if($uid){
		$where = $where." and userid=$uid";
	}

    // 分页处理开始
    $csql = "SELECT COUNT(*) AS rs_count FROM $tbl_ad $where";
    $rs   = $conn->GetRow($csql);


    $record_total   = @(int)$rs['rs_count'];
    $page_total     = ceil($record_total/$page_size);

    $page   = @(int)$_GET['page'];
    if($page < 1) $page = 1;
    if($page > $page_total && $page_total > 0) $page = $page_total;
    $offset = ($page - 1) * $page_size;
    $limit  = "LIMIT $offset, $page_size";

    $view_var['record_total']   = $record_total;
    $view_var['page_total']     = $page_total;
    $view_var['page']           = $page;
    $view_var['page_size']      = $page_size;
    // 分页处理完毕


    // 列表处理开始
    $order_by   = trim(@$_GET['orderby']);
    $order_desc = @(int)$_GET['desc'];

    $str_order_by   = '';
    if($order_by != '') {
        $order_desc = ($order_desc!=1)?'ASC':'DESC';
        $str_order_by = "`{$order_by}` {$order_desc}, ";
    }

    $sql    = "SELECT * FROM $tbl_ad
            $where 
            ORDER BY  $str_order_by id DESC 
            ";
    $rs = $conn->PageExecute($sql,$page_size,$page);
    $view_var['record'] = $rs->GetRows();
    // 列表处理结束


    return $view_var;
}

?>